﻿namespace Core.Helper
{
    public static class Regex
    {
        /// <summary>
        /// 通用登录名规则
        /// 必须是数字和字母的组合，6-20位
        /// </summary>
        public const string LoginName = @"(^[A-Za-z0-9]+$){6,20}";
        /// <summary>
        /// 通用密码规则
        /// 必须是数字和字母的组合，6-20位
        /// </summary>
        public const string Password = @"(^[A-Za-z0-9]+$){6,20}";
        /// <summary>
        /// 邮箱
        /// </summary>
        public const string Email = @"\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*";
        /// <summary>
        /// 双字节，主要用来兼容中文
        /// </summary>
        public const string DoubleByte = @"[^\x00-\xff]";
        /// <summary>
        /// 只包含简体中文
        /// </summary>
        public const string OnlyChinese = @"^[\u4e00-\u9fa5]+$";
        /// <summary>
        /// 只包含数字
        /// </summary>
        public const string OnlyNumber = @"^[0-9]+$";
        /// <summary>
        /// 只包含26个大小写英文字母
        /// </summary>
        public const string OnlyLetter = @"^[A-Za-z]+$";
        /// <summary>
        /// 固话
        /// </summary>
        public const string Tel = @"\d{3}-\d{8}|\d{4}-\d{7}";
        /// <summary>
        /// 只包含数字和26个大小写英文字母
        /// </summary>
        public const string LetterNumber = @"^[A-Za-z0-9]+$";
        /// <summary>
        /// 小数
        /// </summary>
        public const string Float = @"^[+-]?([0-9]*\.?[0-9]+|[0-9]+\.?[0-9]*)([eE][+-]?[0-9]+)?$";
        /// <summary>
        /// 手机号码
        /// </summary>
        public const string Mobile = @"^[1]+[3,4,5,7,8]+\d{9}";
        /// <summary>
        /// QQ号码
        /// </summary>
        public const string QQ = @"[1-9][0-9]{5,9}";
        /// <summary>
        /// 网址
        /// </summary>
        public const string Url = @"[a-zA-z]+://[^\s]*";
        /// <summary>
        /// 邮政编码
        /// </summary>
        public const string ZipCode = @"[1-9]\d{5}(?!\d)";
        /// <summary>
        /// 年份
        /// </summary>
        public const string Year = @"^((19\d{2})|(2\d{3}))$";
        /// <summary>
        /// 月份
        /// </summary>
        public const string Month = @"^(0?[[1-9]|1[0-2])$";
        /// <summary>
        /// 只有0
        /// </summary>
        public const string Zero = @"0";
        /// <summary>
        /// 没有特殊字符
        /// </summary>
        public const string NonSpecialLetters = @"^[A-Za-z0-9\u4e00-\u9fa5]+$";
        /// <summary>
        /// IP地址
        /// </summary>
        public const string IP = @"^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$";
        /// <summary>
        /// 日期格式
        /// </summary>
        public const string Date = @"^((((1[6-9]|[2-9]\d)\d{2})-(0?[13578]|1[02])-(0?[1-9]|[12]\d|3[01]))|(((1[6-9]|[2-9]\d)\d{2})-(0?[13456789]|1[012])-(0?[1-9]|[12]\d|30))|(((1[6-9]|[2-9]\d)\d{2})-0?2-(0?[1-9]|1\d|2[0-9]))|(((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))-0?2-29-))$";
        /// <summary>
        /// 日期+时间格式
        /// </summary>
        public const string DateTime = @"^(((((1[6-9]|[2-9]\d)\d{2})-(0?[13578]|1[02])-(0?[1-9]|[12]\d|3[01]))|(((1[6-9]|[2-9]\d)\d{2})-(0?[13456789]|1[012])-(0?[1-9]|[12]\d|30))|(((1[6-9]|[2-9]\d)\d{2})-0?2-(0?[1-9]|1\d|2[0-8]))|(((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))-0?2-29-)) (20|21|22|23|[0-1]?\d):[0-5]?\d:[0-5]?\d)$ ";
        /// <summary>
        /// 版本号
        /// </summary>
        public const string Version = @"^\d{1,2}.\d{1,2}.\d{1,2}.\d{1,2}$";
    }
}